package dungeonPackage;

import squareBorderPackage.Square;
import be.kuleuven.cs.som.annotate.*;

/**
 * A class of exceptions signaling illegal temperatures for squares.
 * 
 * @version 1.0
 * @author Esther Alberts and Jessa Bekker
 * 
 */

public class InvalidSquareAdditionException extends RuntimeException {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6327364668317540791L;

	/**
	 * Initialize this new invalid square addition exception with given dungeon
	 * and given square.
	 * 
	 * @param dungeon
	 *            The dungeon for this new invalid square addition exception.
	 * @param square
	 *            The square for this new invalid square addition exception.
	 * @post The dungeon of this new invalid square addition exception is the
	 *       same as the given dungeon |new.getDungeon() == dungeon
	 * @post The square for this new invalid square addition exception is the
	 *       same as the given square |new.getSquare() == square
	 * @post The message for this new illegal temperature exception will be 'The
	 *       percentage of squares with a slippery flooring would get to high if
	 *       a square with a slippery flooring was added.' if there can't be
	 *       added an extra square with a slippery flooring to the given dungeon
	 *       and the given square has a slippery flooring. | if(!
	 *       dungeon.canAddSlipperyFlooring() && square.getSlipperyFlooring()) |
	 *       then( getMessage() ==
	 *       "The percentage of squares with a slippery flooring would" + |
	 *       "get to high if a square with a slippery flooring was added." |
	 * @effect This new invalid square addition exception has further no cause
	 *         |super()
	 */
	public InvalidSquareAdditionException(Dungeon dungeon, Square square) {
		this.dungeon = dungeon;
		this.square = square;
		String message = "";
		if (!dungeon.canAddSlipperyFlooring() && square.getSlipperyFlooring())
			message = "The percentage of squares with a slippery flooring would get"
					+ "to high if a square with a slippery flooring was added.";
		this.message = message;
	}

	/**
	 * Return the message of this illegal temperature exception.
	 */
	@Basic
	@Immutable
	public String getMessage() {
		return message;
	}

	/**
	 * Variable registering a message of this illegal temperature exception.
	 */
	private final String message;

	/**
	 * Return the temperature of this illegal temperature exception.
	 */
	@Basic
	@Immutable
	public Dungeon getDungeon() {
		return dungeon;
	}

	/**
	 * Variable registering the temperature of this illegal temperature
	 * exception.
	 */
	private final Dungeon dungeon;

	/**
	 * Return the square of this illegal temperature exception.
	 */
	@Basic
	@Immutable
	public Square getSquare() {
		return square;
	}

	/**
	 * Variable referencing the square of this illegal temperature exception.
	 */
	private final Square square;

}
